Image Optimization by Addy Osmani

Image Optimization by Addy Osmani

Author:Addy Osmani
Language: eng
Format: epub
Tags: Smashing eBooks
Published: 2021-04-22T00:00:00+00:00


stale-while-revalidate (SWR)

The stale-while-revalidate8 HTTP Cache-Control directive sets a grace period in which browsers can use an out-of-date (stale) asset while checking on a new version. This hides network and server latency from clients.

Cache-Control: max-age=31536000, stale-while-revalidate=86400

This Cache-Control header states the amount of time in seconds a file should be cached for (max-age=31536000 — this file should be good for a year). After a year, you have one day to keep serving this stale asset, while it is asynchronously revalidated in the background (stale-while-revalidate=86400 — one day in seconds).

With this directive, you can balance delivering on immediacy — serving content that is cached straightaway — and freshness — making sure that updates to the cached content are used next time. In browsers that don’t support stale-while-revalidate, it will be ignored and max-age values will be used instead.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.